#!/bin/bash
#设定的亮度
PERCENT=$1

if [ -z "$PERCENT" ]; then
	    echo "Usage: $0 <brightness in percent>"
	        exit 1
fi

# 设备路径
BACKLIGHT_PATH="/sys/class/backlight/intel_backlight"

# 获取最大亮度
MAX_BRIGHTNESS=$(cat $BACKLIGHT_PATH/max_brightness)

# 计算新的亮度值
NEW_BRIGHTNESS=$(($MAX_BRIGHTNESS * $PERCENT / 100))

# 设置新的亮度值
echo $NEW_BRIGHTNESS | sudo tee $BACKLIGHT_PATH/brightness
